package mt.dummy;

import static org.junit.Assert.*;

import java.util.ArrayList;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class ClientTableModelTest {

	private ClientTableModel clientTable;

	String[] header = { "Stock", "Number of units", "Price per unit" };
	int rowIndex = 0 ;
	int columnIndex =0;
	Object[][] obj = new Object[2][2];
	boolean buyOrder = true ;

	@Before
	public void setUp() throws Exception {

		
		clientTable = new ClientTableModel(obj , header);
	    obj[0][0] = "a";
	    obj[0][1] = "10";
	    obj[1][0] = "b";
	    obj[1][1] = "30";
		assertNotNull(clientTable.al); 

	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testClientTableModel() {
		assertNotNull(clientTable);
	}

	@Test
	public void testGetRowCount() {

		assertEquals(clientTable.getRowCount(), 2);

	}

	@Test
	public void testGetColumnCount() {

		assertEquals(clientTable.getColumnCount(), 3);
	}

	@Test
	public void testGetValueAt() {

		
		assertEquals(clientTable.getValueAt(0, 0), "a");
	}

	@Test
	public void testGetColumnNameInt() {

		assertEquals(clientTable.getColumnName(0), "Stock");
		assertEquals(clientTable.getColumnName(1), "Number of units");
		assertEquals(clientTable.getColumnName(2), "Price per unit");
	}

	@Test
	public void testAdd() {
		
		clientTable.add("a", "2", "3", true);
		assertEquals(clientTable.getValueAt(0, 1), "8");
		
		clientTable.add("b", "10", "3", false);
		assertEquals(clientTable.getValueAt(1, 1), "40");
		
		clientTable.add(null, null, null, false);
		assertEquals(clientTable.getValueAt(0, 1), "8");
		

		clientTable.add("b", "40", "3", true);
		assertEquals(clientTable.getValueAt(1, 1), null);
	
		
		assertNotNull(clientTable);
			
	}

}
